package com.dgut.legalservice.controller;

import com.dgut.legalservice.domain.Approval;
import com.dgut.legalservice.service.ApprovalService;
import com.dgut.legalservice.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/process")
public class ProcessController {
    @Autowired
    private ApprovalService approvalService;
    @Autowired
    private ProcessService processService;

    /**
     * 审核成功
     * @param orderId
     */
    @RequestMapping("/{who}/success/{orderId}")
    public void setPlaSuce(@PathVariable Integer orderId, @PathVariable String who){
        Approval approval = new Approval();
        approval.setResult(who+"审核成功");
        approval.setUpdateTime(new Date());
        approval.setCreateTime(new Date());
        approvalService.setFirStatus(approval, orderId);
    }

    /**
     * 审核失败
     * @param orderId
     */
    @RequestMapping("/{who}/fail/{orderId}")
    public void setPlaFai(@PathVariable Integer orderId,@PathVariable String who){
        Approval approval = new Approval();
        approval.setResult(who+"审核失败");
        approval.setUpdateTime(new Date());
        approval.setCreateTime(new Date());
        approvalService.setFirStatus(approval, orderId);
    }

//    /**
//     * 服务方审核成功
//     * @param orderId
//     */
//    @RequestMapping("/server/success")
//    public void setServ(Integer orderId) {
//        Approval approval = new Approval();
//        approval.setResult("服务方审核成功");
//        approval.setUpdateTime(new Date());
//        approval.setCreateTime(new Date());
//        approvalService.setFirStatus(approval, orderId);
//    }
//
//    /**
//     * 服务方审核失败
//     * @param orderId
//     */
//    @RequestMapping("/server/fail")
//    public void setServFail(Integer orderId) {
//        Approval approval = new Approval();
//        approval.setResult("服务方审核失败");
//        approval.setUpdateTime(new Date());
//        approval.setCreateTime(new Date());
//        approvalService.setFirStatus(approval, orderId);
//    }
//
//    @RequestMapping("/user/change")
//    public void setChange(Integer orderId){
//        Approval approval = new Approval();
//        approval.setResult("服务方审核失败");
//        approval.setUpdateTime(new Date());
//        approval.setCreateTime(new Date());
//        approvalService.setFirStatus(approval, orderId);
//    }
}
